﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1442102, 0),
Array("", 1442104, 0),
Array("", 1442105, 0),
Array("", 1442106, 0),
Array("", 1442107, 0),
Array("", 1442108, 0),
Array("", 1442109, 0),
Array("", 1442110, 0),
Array("", 1442111, 0),
Array("", 1442113, 0),
Array("", 1442115, 0),
Array("", 1442116, 0),
Array("", 1442117, 0),
Array("", 1442118, 0),
Array("", 1442119, 0),
Array("", 1442120, 0),
Array("", 1442121, 0),
Array("", 1442122, 0),
Array("", 1442123, 0),
Array("", 1442124, 0),
Array("", 1442125, 0),
Array("", 1442126, 0),
Array("", 1442127, 0),
Array("", 1442128, 0),
Array("", 1442129, 0),
Array("", 1442130, 0),
Array("", 1442131, 0),
Array("", 1442132, 0),
Array("", 1442133, 0),
Array("", 1442135, 0),
Array("", 1442136, 0),
Array("", 1442137, 0),
Array("", 1442138, 0),
Array("", 1442139, 0),
Array("", 1442140, 0),
Array("", 1442141, 0),
Array("", 1442142, 0),
Array("", 1442143, 0),
Array("", 1442144, 0),
Array("", 1442145, 0),
Array("", 1442146, 0),
Array("", 1442147, 0),
Array("", 1442148, 0),
Array("", 1442149, 0),
Array("", 1442150, 0),
Array("", 1442151, 0),
Array("", 1442152, 0),
Array("", 1442153, 0),
Array("", 1442154, 0),
Array("", 1442155, 0),
Array("", 1442156, 0),
Array("", 1442157, 0),
Array("", 1442159, 0),
Array("", 1442160, 0),
Array("", 1442161, 0),
Array("", 1442162, 0),
Array("", 1442163, 0),
Array("", 1442164, 0),
Array("", 1442169, 0),
Array("", 1442170, 0),
Array("", 1442171, 0),
Array("", 1442173, 0),
Array("", 1442180, 0),
Array("", 1442181, 0),
Array("", 1442182, 0),
Array("", 1442183, 0),
Array("", 1442185, 0),
Array("", 1442186, 0),
Array("", 1442187, 0),
Array("", 1442188, 0),
Array("", 1442189, 0),
Array("", 1442190, 0),
Array("", 1442191, 0),
Array("", 1442202, 0),
Array("", 1442203, 0),
Array("", 1442204, 0),
Array("", 1442205, 0),
Array("", 1442209, 0),
Array("", 1452000, 0),
Array("", 1452001, 0),
Array("", 1452002, 0),
Array("", 1452003, 0),
Array("", 1452004, 0),
Array("", 1452005, 0),
Array("", 1452006, 0),
Array("", 1452007, 0),
Array("", 1452008, 0),
Array("", 1452009, 0),
Array("", 1452010, 0),
Array("", 1452011, 0),
Array("", 1452012, 0),
Array("", 1452013, 0),
Array("", 1452014, 0),
Array("", 1452015, 0),
Array("", 1452016, 0),
Array("", 1452017, 0),
Array("", 1452018, 0),
Array("", 1452019, 0),
Array("", 1452020, 0),
Array("", 1452021, 0),
Array("", 1452022, 0),
Array("", 1452023, 0),
Array("", 1452024, 0),
Array("", 1452025, 0),
Array("", 1452026, 0),
Array("", 1452027, 0),
Array("", 1452028, 0),
Array("", 1452029, 0),
Array("", 1452030, 0),
Array("", 1452031, 0),
Array("", 1452032, 0),
Array("", 1452033, 0),
Array("", 1452034, 0),
Array("", 1452035, 0),
Array("", 1452036, 0),
Array("", 1452038, 0),
Array("", 1452039, 0),
Array("", 1452040, 0),
Array("", 1452041, 0),
Array("", 1452042, 0),
Array("", 1452044, 0),
Array("", 1452045, 0),
Array("", 1452046, 0),
Array("", 1452048, 0),
Array("", 1452049, 0),
Array("", 1452050, 0),
Array("", 1452051, 0),
Array("", 1452057, 0),
Array("", 1452058, 0),
Array("", 1452059, 0),
Array("", 1452060, 0),
Array("", 1452062, 0),
Array("", 1452063, 0),
Array("", 1452064, 0),
Array("", 1452066, 0),
Array("", 1452067, 0),
Array("", 1452068, 0),
Array("", 1452069, 0),
Array("", 1452070, 0),
Array("", 1452071, 0),
Array("", 1452073, 0),
Array("", 1452077, 0),
Array("", 1452078, 0),
Array("", 1452079, 0),
Array("", 1452083, 0),
Array("", 1452084, 0),
Array("", 1452085, 0),
Array("", 1452090, 0),
Array("", 1452091, 0),
Array("", 1452092, 0),
Array("", 1452093, 0),
Array("", 1452096, 0),
Array("", 1452099, 0),
Array("", 1452100, 0),
Array("", 1452101, 0),
Array("", 1452102, 0),
Array("", 1452103, 0),
Array("", 1452104, 0),
Array("", 1452105, 0),
Array("", 1452106, 0),
Array("", 1452107, 0),
Array("", 1452108, 0),
Array("", 1452109, 0),
Array("", 1452110, 0),
Array("", 1452111, 0),
Array("", 1452112, 0),
Array("", 1452113, 0),
Array("", 1452114, 0),
Array("", 1452115, 0),
Array("", 1452116, 0),
Array("", 1452117, 0),
Array("", 1452118, 0),
Array("", 1452119, 0),
Array("", 1452120, 0),
Array("", 1452121, 0),
Array("", 1452122, 0),
Array("", 1452123, 0),
Array("", 1452124, 0),
Array("", 1452125, 0),
Array("", 1452126, 0),
Array("", 1452128, 0),
Array("", 1452129, 0),
Array("", 1452130, 0),
Array("", 1452131, 0),
Array("", 1452132, 0),
Array("", 1452133, 0),
Array("", 1452134, 0),
Array("", 1452135, 0),
Array("", 1452136, 0),
Array("", 1452137, 0),
Array("", 1452138, 0),
Array("", 1452139, 0),
Array("", 1452140, 0),
Array("", 1452141, 0),
Array("", 1452142, 0),
Array("", 1452143, 0),
Array("", 1452144, 0),
Array("", 1452145, 0),
Array("", 1452146, 0),
Array("", 1452147, 0),
Array("", 1452148, 0),
Array("", 1452149, 0),
Array("", 1452151, 0),
Array("", 1452152, 0),
Array("", 1452153, 0),
Array("", 1452154, 0),
Array("", 1452155, 0),
Array("", 1452156, 0),
Array("", 1452162, 0),
Array("", 1452163, 0),
Array("", 1452165, 0),
Array("", 1452166, 0),
Array("", 1452167, 0),
Array("", 1452168, 0),
Array("", 1452169, 0),
Array("", 1452170, 0),
Array("", 1452171, 0),
Array("", 1452173, 0),
Array("", 1452174, 0),
Array("", 1452189, 0),
Array("", 1452190, 0),
Array("", 1452191, 0),
Array("", 1452192, 0),
Array("", 1452196, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到矛,弓店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}